package com.qfedu.roomselectservice.controller;

import com.qfedu.entity.Img;
import com.qfedu.entity.Room;
import com.qfedu.roomselectservice.service.ImgService;
import com.qfedu.roomselectservice.service.RoomService;
import com.qfedu.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：罗小宇
 * 日期：2020/7/3
 */
@RestController
@RequestMapping("room")
public class RoomController {
    @Resource
    private RoomService roomService;
    @Resource
    private ImgService imgService;
    /**
     * 根据roomid查询房间信息、查询图片信息
     * @param roomId
     * @return ResultVo
     */
    @RequestMapping(value = "/query/{roomId}",method = RequestMethod.GET)
    public Map<String,Object> roomSelect(@PathVariable("roomId")Integer roomId){
        Room room = roomService.selectById(roomId);
        List<Img> imgs = imgService.selectImgByRoomId(roomId);
        Map<String,Object> map = new HashMap();
        map.put("room",room);
        map.put("imgs",imgs);
        return map;
    }

}
